//
//  UIApplication+keyWindow.swift
//  GT FM Radio
//
//  Created by macmini01 on 2024/8/16.
//

import Foundation
import UIKit

extension UIApplication {
    public var fmKeyWindow: UIWindow? {
        return UIApplication.shared.connectedScenes
            .filter { $0.activationState == .foregroundActive }
            .compactMap { $0 as? UIWindowScene }
            .flatMap { $0.windows }
            .first { $0.isKeyWindow }
    }
    
    public var fmWindowScene: UIWindowScene? {
        return UIApplication.shared.connectedScenes
            .filter { $0.activationState == .foregroundActive }
            .compactMap { $0 as? UIWindowScene }.first
    }
}
